import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      name:'cesiumx',
      meta: {
        title: 'cesiumx'
      },
      component:()=>import('./views/Main')
    },
    {
      path: '/hello',
      name:'cesium',
      meta: {
        title: 'cesium'
      },
      component:()=>import('./views/HelloWorld')
    },
  ]
})


// eslint-disable-next-line no-unused-vars
router.beforeEach((to, from, next) => {
  if (to.meta.title) {//如果设置标题，拦截后设置标题
    document.title = to.meta.title
  }
  next()
})

export default router;